<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<html >
<head>
    <meta charset="UTF-8">
    <title>Contests - Online Judge</title>
    <link rel="stylesheet" th:href="@{/css/styles.css}" >
    <script th:src="@{/js/jquery-1.7.2.js}"></script>
    <script th:src="@{/js/gdoj.js}"></script>
</head>
<body>
<div th:replace="common::web-navbar"></div>
<div class="container">
    <div class="content">
        <div class="content-with-sidebar">
            <div th:replace="admin/admin-common::admin-navbar"></div>
            <div class="roundbox">
                <div>
                    <table class="contest rtable">
                        <tr class="header">
                            <th class="title left-item">[[#{contesttitle}]]</th>
                            <th class="start">[[#{starttime}]]</th>
                            <th class="during">[[#{during}]]</th>
                            <th class="coder">[[#{createuser}]]</th>
                            <th class=""></th>
                        </tr>
                        <tr th:if="${pageInfo.size == 0}"><td class="left-item dark" colspan="15" style="text-align: left;">There is no records.</td></tr>
                        <tr th:each="contest,stat : ${pageInfo.list}" th:class="${stat.odd}?'dark'">
                            <td class="title left-item">
                                <a th:href="@{/admin/contest/{contestId}(contestId=${contest.contest_id})}" th:text="${contest.title}"></a>
                            </td>
                            <td class="start" th:text="${#dates.format(contest.start_time,'yyyy-MM-dd HH:mm:ss')}"></td>
                            <td class="during"
                                th:title="${#dates.format(contest.start_time,'yyyy-MM-dd HH:mm:ss')} + ' ' + ${#dates.format(contest.end_time,'yyyy-MM-dd HH:mm:ss')}"
                                th:text="${#dates.format(#dates.create(0,0,0,0,0,0,(contest.end_time.getTime() - contest.start_time.getTime())),'HH:mm:ss')}">
                            </td>
                            <td class="coder">
                                <a th:href="@{/profile/{username}(username=${contest.user.username})}" class="rated-user"
                                   th:classappend="'user-rate-' + ${contest.user.rate} + ' user-tip'"
                                   th:user="${contest.user.username}"
                                   th:text="${contest.user.nickname}">
                                </a>
                            </td>
                            <td class="">
                                <a th:href="@{/admin/contest/edit/{contestId}(contestId=${contest.contest_id})}">Edit</a>
                                <a th:if="${contest.defunct=='N'}" th:href="@{/admin/contest/delete/{contestId}(contestId=${contest.contest_id})}">Delete</a>
                                <a th:if="${contest.defunct!='N'}" th:href="@{/admin/contest/resume/{contestId}(contestId=${contest.contest_id})}" style="color: red;font-weight: bold;">Resume</a>
                            </s:else>
                            </td>
                        </tr>
                    </table>
                    <div style="margin:6px 12px;font-size:15px;">
                        <div class="left"></div>
                        <div class="right">
                            <a th:if="${pageInfo.hasPreviousPage == true}" th:href="@{/admin/contests/page/{pageNum}(pageNum=${pageInfo.prePage})}" style="color:#000;text-decoration: none;">&larr;</a>
                            <a th:if="${pageInfo.firstPage > 1}" th:href="@{/admin/contests/page/1}" style="color:#000;text-decoration: none;">1</a>
                            <span th:if="${pageInfo.firstPage > 2}"  >...</span>
                            <span th:each="nav:${pageInfo.navigatepageNums}">
                                <a th:href="@{/admin/contests/page/{pageNum}(pageNum=${nav})}" th:text="${nav}" th:if="${nav == pageInfo.pageNum}" style="font-weight: bold;color:#000;text-decoration: none;"></a>
                                <a th:href="@{/admin/contests/page/{pageNum}(pageNum=${nav})}" th:text="${nav}" th:if="${nav != pageInfo.pageNum}" style="color:#000;text-decoration: none;"></a>
                            </span>
                            <span th:if="${pageInfo.lastPage < pageInfo.pages}" >...</span>
                            <a th:if="${pageInfo.pages > pageInfo.lastPage}" th:href="@{/admin/contests/page/{pageNum}(pageNum=${pageInfo.pages})}" th:text="${pageInfo.pages}" style="color:#000;text-decoration: none;"></a>
                            <a th:if="${pageInfo.hasNextPage == true}" th:href="@{/admin/contests/page/{pageNum}(pageNum=${pageInfo.nextPage})}" style="color:#000;text-decoration: none;">&rarr;</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="sidebar" >
            <div class="sidebox roundbox ">
                <div class="top-link">
                    <div class="title-sidebox">
                        <div class="title-sidebox">Tools Box</div>
                    </div>
                </div>
                <div class="top10" style="margin: 6px;">
                    <b><a th:href="@{/admin/contest/new}">[[#{contestadd}]]</a></b>
                </div>
                <div class="bottom-link">
                </div>
            </div>
        </div>
    </div>
    <div th:replace="common::web-footer"></div>
</div>

</body>
</html>
